import 'package:distribution_mall_flutter/generated/json/base/json_convert_content.dart';
import 'package:distribution_mall_flutter/entity/pay/pay.dart';

OrderPaymentEntity $OrderPaymentEntityFromJson(Map<String, dynamic> json) {
  final OrderPaymentEntity orderPaymentEntity = OrderPaymentEntity();
  final String? distributionOrderId = jsonConvert.convert<String>(
      json['distributionOrderId']);
  if (distributionOrderId != null) {
    orderPaymentEntity.distributionOrderId = distributionOrderId;
  }
  final String? receiptPaymentId = jsonConvert.convert<String>(
      json['receiptPaymentId']);
  if (receiptPaymentId != null) {
    orderPaymentEntity.receiptPaymentId = receiptPaymentId;
  }
  final String? paymentType = jsonConvert.convert<String>(json['paymentType']);
  if (paymentType != null) {
    orderPaymentEntity.paymentType = paymentType;
  }
  final String? paymentMethodName = jsonConvert.convert<String>(
      json['paymentMethodName']);
  if (paymentMethodName != null) {
    orderPaymentEntity.paymentMethodName = paymentMethodName;
  }
  final String? usageProcess = jsonConvert.convert<String>(
      json['usageProcess']);
  if (usageProcess != null) {
    orderPaymentEntity.usageProcess = usageProcess;
  }
  final String? state = jsonConvert.convert<String>(json['state']);
  if (state != null) {
    orderPaymentEntity.state = state;
  }
  final String? currency = jsonConvert.convert<String>(json['currency']);
  if (currency != null) {
    orderPaymentEntity.currency = currency;
  }
  final double? paymentAmount = jsonConvert.convert<double>(
      json['paymentAmount']);
  if (paymentAmount != null) {
    orderPaymentEntity.paymentAmount = paymentAmount;
  }
  final String? payParamsType = jsonConvert.convert<String>(
      json['payParamsType']);
  if (payParamsType != null) {
    orderPaymentEntity.payParamsType = payParamsType;
  }
  final ExternalUrlParams? externalUrlParams = jsonConvert.convert<
      ExternalUrlParams>(json['externalUrlParams']);
  if (externalUrlParams != null) {
    orderPaymentEntity.externalUrlParams = externalUrlParams;
  }
  final BankRemitParams? bankRemitParams = jsonConvert.convert<BankRemitParams>(
      json['bankRemitParams']);
  if (bankRemitParams != null) {
    orderPaymentEntity.bankRemitParams = bankRemitParams;
  }
  return orderPaymentEntity;
}

Map<String, dynamic> $OrderPaymentEntityToJson(OrderPaymentEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['distributionOrderId'] = entity.distributionOrderId;
  data['receiptPaymentId'] = entity.receiptPaymentId;
  data['paymentType'] = entity.paymentType;
  data['paymentMethodName'] = entity.paymentMethodName;
  data['usageProcess'] = entity.usageProcess;
  data['state'] = entity.state;
  data['currency'] = entity.currency;
  data['paymentAmount'] = entity.paymentAmount;
  data['payParamsType'] = entity.payParamsType;
  data['externalUrlParams'] = entity.externalUrlParams?.toJson();
  data['bankRemitParams'] = entity.bankRemitParams?.toJson();
  return data;
}

extension OrderPaymentEntityExtension on OrderPaymentEntity {
  OrderPaymentEntity copyWith({
    String? distributionOrderId,
    String? receiptPaymentId,
    String? paymentType,
    String? paymentMethodName,
    String? usageProcess,
    String? state,
    String? currency,
    double? paymentAmount,
    String? payParamsType,
    ExternalUrlParams? externalUrlParams,
    BankRemitParams? bankRemitParams,
  }) {
    return OrderPaymentEntity()
      ..distributionOrderId = distributionOrderId ?? this.distributionOrderId
      ..receiptPaymentId = receiptPaymentId ?? this.receiptPaymentId
      ..paymentType = paymentType ?? this.paymentType
      ..paymentMethodName = paymentMethodName ?? this.paymentMethodName
      ..usageProcess = usageProcess ?? this.usageProcess
      ..state = state ?? this.state
      ..currency = currency ?? this.currency
      ..paymentAmount = paymentAmount ?? this.paymentAmount
      ..payParamsType = payParamsType ?? this.payParamsType
      ..externalUrlParams = externalUrlParams ?? this.externalUrlParams
      ..bankRemitParams = bankRemitParams ?? this.bankRemitParams;
  }
}

BankRemitParams $BankRemitParamsFromJson(Map<String, dynamic> json) {
  final BankRemitParams bankRemitParams = BankRemitParams();
  final String? bankAccountName = jsonConvert.convert<String>(
      json['bankAccountName']);
  if (bankAccountName != null) {
    bankRemitParams.bankAccountName = bankAccountName;
  }
  final String? bankName = jsonConvert.convert<String>(json['bankName']);
  if (bankName != null) {
    bankRemitParams.bankName = bankName;
  }
  final String? bankAccount = jsonConvert.convert<String>(json['bankAccount']);
  if (bankAccount != null) {
    bankRemitParams.bankAccount = bankAccount;
  }
  final String? checkCode = jsonConvert.convert<String>(json['checkCode']);
  if (checkCode != null) {
    bankRemitParams.checkCode = checkCode;
  }
  final String? description = jsonConvert.convert<String>(json['description']);
  if (description != null) {
    bankRemitParams.description = description;
  }
  return bankRemitParams;
}

Map<String, dynamic> $BankRemitParamsToJson(BankRemitParams entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['bankAccountName'] = entity.bankAccountName;
  data['bankName'] = entity.bankName;
  data['bankAccount'] = entity.bankAccount;
  data['checkCode'] = entity.checkCode;
  data['description'] = entity.description;
  return data;
}

extension BankRemitParamsExtension on BankRemitParams {
  BankRemitParams copyWith({
    String? bankAccountName,
    String? bankName,
    String? bankAccount,
    String? checkCode,
    String? description,
  }) {
    return BankRemitParams()
      ..bankAccountName = bankAccountName ?? this.bankAccountName
      ..bankName = bankName ?? this.bankName
      ..bankAccount = bankAccount ?? this.bankAccount
      ..checkCode = checkCode ?? this.checkCode
      ..description = description ?? this.description;
  }
}

ExternalUrlParams $ExternalUrlParamsFromJson(Map<String, dynamic> json) {
  final ExternalUrlParams externalUrlParams = ExternalUrlParams();
  final String? receiptUrl = jsonConvert.convert<String>(json['receiptUrl']);
  if (receiptUrl != null) {
    externalUrlParams.receiptUrl = receiptUrl;
  }
  final String? qrCodeInfo = jsonConvert.convert<String>(json['qrCodeInfo']);
  if (qrCodeInfo != null) {
    externalUrlParams.qrCodeInfo = qrCodeInfo;
  }
  return externalUrlParams;
}

Map<String, dynamic> $ExternalUrlParamsToJson(ExternalUrlParams entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['receiptUrl'] = entity.receiptUrl;
  data['qrCodeInfo'] = entity.qrCodeInfo;
  return data;
}

extension ExternalUrlParamsExtension on ExternalUrlParams {
  ExternalUrlParams copyWith({
    String? receiptUrl,
    String? qrCodeInfo,
  }) {
    return ExternalUrlParams()
      ..receiptUrl = receiptUrl ?? this.receiptUrl
      ..qrCodeInfo = qrCodeInfo ?? this.qrCodeInfo;
  }
}

PaymentStateEntity $PaymentStateEntityFromJson(Map<String, dynamic> json) {
  final PaymentStateEntity paymentStateEntity = PaymentStateEntity();
  final String? receiptPaymentId = jsonConvert.convert<String>(
      json['receiptPaymentId']);
  if (receiptPaymentId != null) {
    paymentStateEntity.receiptPaymentId = receiptPaymentId;
  }
  final String? paymentState = jsonConvert.convert<String>(
      json['paymentState']);
  if (paymentState != null) {
    paymentStateEntity.paymentState = paymentState;
  }
  return paymentStateEntity;
}

Map<String, dynamic> $PaymentStateEntityToJson(PaymentStateEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['receiptPaymentId'] = entity.receiptPaymentId;
  data['paymentState'] = entity.paymentState;
  return data;
}

extension PaymentStateEntityExtension on PaymentStateEntity {
  PaymentStateEntity copyWith({
    String? receiptPaymentId,
    String? paymentState,
  }) {
    return PaymentStateEntity()
      ..receiptPaymentId = receiptPaymentId ?? this.receiptPaymentId
      ..paymentState = paymentState ?? this.paymentState;
  }
}